import request from '@/utils/request'

export const fetchPriceCategories = params => {
  return request({
    url: '/price-categories',
    params
  })
}
export const addPriceCategory = data => {
  return request({
    url: '/price-categories',
    method: 'post',
    data
  })
}
export const updatePriceCategory = (data, id) => {
  return request({
    url: `/price-categories/${id}`,
    method: 'put',
    data
  })
}
export const fetchBookRule = params => {
  return request({
    url: '/book-rules',
    params
  })
}
export const addBookRule = data => {
  return request({
    url: '/book-rules',
    method: 'post',
    data
  })
}
export const updateBookRule = (data, id) => {
  return request({
    url: `/book-rules/${id}`,
    method: 'put',
    data
  })
}

export const settleBookRule = (data, id) => {
  return request({
    url: `/book-rules/${id}/settle`,
    method: 'put',
    data
  })
}

export const addBookRulePrice = data => {
  return request({
    url: '/book-rule-prices',
    method: 'post',
    data
  })
}
export const updateBookRulePrice = (data, id) => {
  return request({
    url: `/book-rule-prices/${id}`,
    method: 'put',
    data
  })
}
export const delBookRulePrice = id => {
  return request({
    url: `/book-rule-prices/${id}`,
    method: 'delete'
  })
}
export const delBookRule = id => {
  return request({
    url: `/book-rules/${id}`,
    method: 'delete'
  })
}
